﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Messaging;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using HotShot.Service.Entities;
using HotShot.Entities.Messages;

namespace HotShot.Service.BusinessLogic.Worker
{
    public class GlobalCommunicationWorker: WorkerBase
    {
        protected override Guid ProcessorId
        {
            get { return Guid.NewGuid(); }
        }

        protected override bool Work()
        {
            var message = QueueCommunicationLogic.Current.GetGlobalMessage();
            if (message != null)
            {
                string cid = message.CorrelationId;
                if (cid.StartsWith(Guid.Empty.ToString())) cid = message.Id;
                MessagingLogic.Current.ProcessMessage(message.Body as BaseMessage, cid, true);
            }

            return message != null;
        }
    }
}
